<template>
	<view class="dataform">
		<view class="title">
			<!-- <contentSw :swlist="conSwlist" @conswitch="conswitch"></contentSw> -->
			<u-tabs :list="conSwlist" :is-scroll="false" :current="currentTapindex" @change="tabChange"></u-tabs>
			<view class="content_title">
				<picker mode="date" @change="dateSel" :value="currentDate" fields="month">
					<view>
						<text>{{currentDate}}</text>
						<image src="../../static/img/my_back.png" mode=""></image>
					</view>
				</picker>
			</view>
		</view>
		<scroll-view class="content" scroll-y="true">
			<view class="content_list">
				<view class="list_item" v-for="(value, key, index) in dataVal" @click="disDetail(key)">
					<view class="item_title">
						<text class="item_titleLeft">{{value.title}}</text>
						<view class="item_titleRight">
							<text>更多</text>
							<image src="../../static/img/my_back.png"></image>
						</view>
					</view>
					<view class="item_con">
						<view class="item_conEve">
							<view class="item_conEve_con">{{value.num}}</view>
							<view class="item_conEve_title">交易笔数</view>
						</view>
						<view class="item_conEve">
							<view class="item_conEve_con">{{value.money}}</view>
							<view class="item_conEve_title">交易金额</view>
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import { index } from '../../api/index.js'
	export default {
		data() {
			return {
				conSwlist:[{name:'全部'},{name:'总代个人'}],
				currentTapindex:0,
				currentDate:'',
				dataVal:{
					'total':{
						title:'总交易数据',
						num:'0',//交易笔数
						money:'0' //交易金额
					},
					'waimai':{
						id:'',
						title:'外卖交易数据统计',
						num:'0',//交易笔数
						money:'0' //交易金额
					},
					'scan':{
						title:'扫码点餐数据统计',
						num:'0',//交易笔数
						money:'0' //交易金额
					},
					'card':{
						title:'台卡交易数据统计',
						num:'0',//交易笔数
						money:'0' //交易金额
					}
				}
			}
		},
		onLoad:function(){
			this.currentDate = this.getDate({
			    format: true
			})
		},
		methods: {
			tabChange:function(index){
				this.currentTapindex = index;
			},
			dateSel:function(e){
				this.currentDate = (e.target.value)
			},
			getDate:function(type) {
			    const date = new Date();
			    let year = date.getFullYear();
			    let month = date.getMonth() + 1;
			
			    if (type === 'start') {
			        year = year - 60;
			    } else if (type === 'end') {
			        year = year + 2;
			    }
			    month = month > 9 ? month : '0' + month;
			    return `${year}-${month}`;
			},
			disDetail:function(key){
				uni.navigateTo({
					url: `../../view/dataformDetail/dataformDetail?id=${key}`
				});
			}
		},
		components:{
			
		}
	}
</script>

<style lang="scss" scoped>
	.dataform{
		height: 100%;
		background-color: #F5F5F5;
		position: relative;
		.title{
			position: absolute;
			left: 0;
			right: 0;
			top: 0;
			width: 100%;
			border-top: 1rpx solid #EEEEEE;
			background-color: #FFFFFF;
			.content_title{
				padding: 20rpx 0 20rpx 20rpx;
				background-color: #F5F5F5;
				image{
					margin-left: 10rpx;
					width: 20rpx;
					height: 20rpx;
					transform: rotate(90deg);
				}
			}
		}
		.content{
			height: 100%;
			padding: 0 30rpx;
			padding-top: 180rpx;
			box-sizing: border-box;
			.content_list{
				.list_item{
					background-color: #FFFFFF;
					border-radius: 10rpx;
					padding: 0 30rpx;
					margin-bottom: 24rpx;
					.item_title{
						display: flex;
						justify-content: space-between;
						padding: 20rpx 0;
						border-bottom: 1rpx solid #E5E5E5;
						.item_titleLeft{
							font-size: $uni-font-size-lg;
							font-weight: bold;
						}
						.item_titleRight{
							display: flex;
							align-items: center;
							color: #666666;
							image{
								width: 32rpx;
								height: 32rpx;
							}
						}
					}
					.item_con{
						display: flex;
						.item_conEve{
							width: 50%;
							text-align: center;
							padding: 40rpx 0;
							.item_conEve_con{
								font-size: 44rpx;
								font-weight: bold;
							}
							.item_conEve_title{
								color: #999999;
								font-size: $uni-font-size-sm;
							}
						}
					}
				}
			}
		}
	}
</style>
